pub trait FinetunePlugin: Send + Sync {
    fn name(&self) -> &str;
    fn prepare_data(&self, dataset: &Path) -> Result<(), Box<dyn Error>>;
    fn run(&self, base_model: &str, output: &str) -> Result<(), Box<dyn Error>>;
}

pub struct FinetuneManager {
    plugins: HashMap<String, Arc<dyn FinetunePlugin>>,
}

impl FinetuneManager {
    pub fn new() -> Self {
        Self { plugins: HashMap::new() }
    }

    pub fn register_plugin(&mut self, plugin: Arc<dyn FinetunePlugin>) {
        self.plugins.insert(plugin.name().to_string(), plugin);
    }

    pub fn run_finetuning(
        &self,
        plugin_name: &str,
        dataset: &Path,
        base_model: &str,
        output: &str,
    ) -> Result<(), Box<dyn Error>> {
        let plugin = self.plugins.get(plugin_name)
            .ok_or("Plugin not found")?;
        plugin.prepare_data(dataset)?;
        plugin.run(base_model, output)
    }
}